# -*-encoding: utf-8 -*-

from utils.logger.LLogger import logger

class Term_Info:

    def __init__(self, mti):
        self.mTermInfo = mti
        self.Max = -1

    def getTermSize(self):
        termInfoFile = open(self.mTermInfo)
        isFirstTwoLine = -2
        while 1:
            lines = termInfoFile.readlines(10000)
            if not lines:
                break
            for line in lines:
                if isFirstTwoLine < 0:
                    isFirstTwoLine += 1
                    continue
                line = line.strip()
                tmpMax = (int)((line.split("\t"))[1].strip())
                logger.debug("%s%s" %(line, str(tmpMax)))
                if tmpMax >= self.Max:
                    self.Max = tmpMax
        termInfoFile.close()
        return self.Max + 1
